class RegisterValue{
    doGetValue(addr, len){
        if(addr < 0x100000000){
            return form("0x%x", addr);
        }

        if(Byte(addr) == 0xffffffffffff){
            return "";
        }

        auto comment, name;
        comment = CommentEx(addr, 1);

        auto i, tmpValue;
        auto result = "";
        for(i = 0; i < len; i++){
            tmpValue = Byte(addr + i);
            if(tmpValue > 0x7E || tmpValue < 0x20){
                result = form("%s.", result);
            } else {
                result = form("%s%s", result, tmpValue);
            } 
        }

        if(comment == ""){
            return result;
        }
        return form("%s  ; %s", result, comment);
    }

    doGetSendMsgValue(addr, len){
        if(addr < 0x100000000){
            return form("0x%x", addr);
        }

        if(Byte(addr) == 0xffffffffffff){
            return "";
        }

        auto i, tmpValue;
        auto result = "";
        for(i = 0; i < len; i++){
            tmpValue = Byte(addr + i);
            if((tmpValue >= 0x41 && tmpValue <= 0x5A) || (tmpValue >= 0x61 && tmpValue <= 0x7A) || (tmpValue >= 0x30 && tmpValue <= 0x39) || tmpValue == 0x3A || tmpValue == 0x5F){
                result = form("%s%s", result, tmpValue);
                continue;
            }
            break; 
        }
        return result;
    }

    getAddr(registerType){
        return this.get(registerType, 0, 0);
    }

    getValue(registerType, len){
        return this.get(registerType, len, 1);
    }

    getSendMsgValue(registerType, len){
        return this.get(registerType, len, 3);
    }

    getName(registerType){
        return this.get(registerType, 0, 2);
    }

    /**
     * type:
     * 0: 获取addr
     * 1: 获取字符串值
     * 2: 获取name
     * 3: 获取SendMsg方法签名字符串值
     */
    get(registerType, len, type){
        auto addr, e;
        try{
            if(registerType == 0 || registerType == "X0" || registerType == "W0"){
                addr = x0;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 1 || registerType == "X1" || registerType == "W1"){
                addr = x1;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 2 || registerType == "X2" || registerType == "W2"){
                addr = x2;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 3 || registerType == "X3" || registerType == "W3"){
                addr = x3;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 4 || registerType == "X4" || registerType == "W4"){
                addr = x4;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 5 || registerType == "X5" || registerType == "W5"){
                addr = x5;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 6 || registerType == "X6" || registerType == "W6"){
                addr = x6;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 7 || registerType == "X7" || registerType == "W7"){
                addr = x7;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 8 || registerType == "X8" || registerType == "W8"){
                addr = x8;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 9 || registerType == "X9" || registerType == "W9"){
                addr = x9;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 10 || registerType == "X10" || registerType == "W10"){
                addr = x10;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 11 || registerType == "X11" || registerType == "W11"){
                addr = x11;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 12 || registerType == "X12" || registerType == "W12"){
                addr = x12;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                } 
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 13 || registerType == "X13" || registerType == "W13"){
                addr = x13;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 14 || registerType == "X14" || registerType == "W14"){
                addr = x14;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 15 || registerType == "X15" || registerType == "W15"){
                addr = x15;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 16 || registerType == "X16" || registerType == "W16"){
                addr = x16;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 17 || registerType == "X17" || registerType == "W17"){
                addr = x17;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 18 || registerType == "X18" || registerType == "W18"){
                addr = x18;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 19 || registerType == "X19" || registerType == "W19"){
                addr = x19;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 20 || registerType == "X20" || registerType == "W20"){
                addr = x20;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 21 || registerType == "X21" || registerType == "W21"){
                addr = x21;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 22 || registerType == "X22" || registerType == "W22"){
                addr = x22;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 23 || registerType == "X23" || registerType == "W23"){
                addr = x23;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 24 || registerType == "X24" || registerType == "W24"){
                addr = x24;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 25 || registerType == "X25" || registerType == "W25"){
                addr = x25;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 26 || registerType == "X26" || registerType == "W26"){
                addr = x26;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 27 || registerType == "X27" || registerType == "W27"){
                addr = x27;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 28 || registerType == "X28" || registerType == "W28"){
                addr = x28;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 29 || registerType == "X29" || registerType == "W29"){
                addr = x29;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 30 || registerType == "X30" || registerType == "W30"){
                addr = x30;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 31 || registerType == "SP"){
                addr = sp;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 32 || registerType == "PC"){
                addr = pc;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            } else if(registerType == 33 || registerType == "PSR"){
                addr = psr;
                if(type == 0){
                    return form("0x%09x", addr);
                } 
                if(type == 1){
                    return this.doGetValue(addr, len);
                }
                if(type == 2){
                    return Name(addr);
                }
                if(type == 3){
                    return this.doGetSendMsgValue(addr, len);
                }
            }
        } catch(e) {
            Message("get register value exception, addr: %s\n", addr);
        }
        return "";
    }

}